package edu.towson.cosc.cosc455.kkarolenko.markdowncompiler;

// Token class for converting markdown to html
public class Token {
	
	private String markdown;
	private String id;
	private String html;
	
	// Constructors
	public Token (String markdown, String id, String html) {
		this.markdown = markdown;
		this.id = id;
		this.html = html;
	}
	
	public Token (String markdown, String id) {
		this(markdown, id, "none");
	}
	
	// Override equals method to easily determine if the markdown of tokens are the same
	@Override
	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		else if (o == this) {
			return true;
		}
		else if (o instanceof String) {
			return markdown.equalsIgnoreCase((String) o);
		}
		else if (o instanceof Token) {
			Token token = (Token) o;
			return (token.markdown.equalsIgnoreCase(markdown) /*&& token.id.equals(id) && token.html.equals(html)*/);
		}
		return false;
	}
	
	// return the markdown
	public String getMD() {
		return markdown;
	}
	
	// return the id
	public String getID() {
		return id;
	}
	
	// return the corresponding html
	public String getHTML() {
		return html;
	}
	
	// Return a string version
	public String toString() {
		return "Markdown: " + markdown + "; ID: " + id + "; HTML: " + html + ";";
	}
}
